package twentytwenty;

/**
 * @Author: Zahi
 * @Description:
 * @Date Created in 2020-12-14 14:32
 * @Modified By:
 */
public class ToHex_405 {
    public static void main(String[] args) {
        int num = 28;
        System.out.println(toHex(num));
    }

    public static String toHex(int num) {
        StringBuffer buffer = new StringBuffer();
        char[] arr ="0123456789abcdef".toCharArray();
        if(num==0) return "0";
        while (num!=0){
            int tmp=num&15;
            buffer.append(arr[tmp]);
            num=num>>>4;
        }

        return buffer.reverse().toString();
    }
}
